import { Component, OnInit } from '@angular/core';
import { NewService } from 'src/app/services/news.service';
import * as constants from '../../../providers/Constants'
import { ToastService } from 'src/app/providers/toast/toast.service';
import { Utils } from 'src/app/providers/Utils';
import { ActivatedRoute, Params } from '@angular/router';
@Component({
  selector: 'app-system-message',
  templateUrl: './system-message.page.html',
  styleUrls: ['./system-message.page.scss'],
})
export class SystemMessagePage implements OnInit {
  array:any=[];
  type:string='0';
  constructor(private mNewService:NewService,private toast:ToastService,private activeRoute: ActivatedRoute,) {
    this.activeRoute.queryParams.subscribe((params: Params) => {
        if (params.type) {
          this.type=params.type;
        }else{
          this.query();
        }
    })
   }

  ngOnInit() {
  }
  query(){
    this.mNewService.getSystemMsg({
      param:'3',
    }).subscribe(res => {
      if (res.retCode == '000000') {
        this.array=res.array;
      } else if (constants.errCode[res.retCode]) {
        if (constants.errCode[res.retCode] != '0') {           this.toast.show(constants.errCode[res.retCode]);         }
       } else if (res.retMsg) {
         this.toast.show(res.retMsg);
       } else {
         this.toast.show("exception service routine");
       }
    })
  }
  strFormatData(str){
    return Utils.strFormatData(str);
  }
}
